<template>
  <div class="img-item">
    <img v-if="item.picUrl" :src="item.picUrl"/>
    <img v-else :src="item.cover"  class="cover">
    <p>{{ item.name }}</p>
    <span v-if="item.playCount">{{ item.playCount | formatNumber }}</span>
  </div>
</template>

<script>
export default {
  props: {
    item: Object,
  },
  filters: {
    formatNumber(value) {
      if (value / 10000 >= 10000) {
        return (value / 100000000).toFixed(1) + "亿";
      } else if (value / 10000 > 0) {
        return (value / 10000).toFixed(1) + "万";
      } else {
        return value;
      }
    },
  },
};
</script>

<style lang="less" scoped>
.img-item {
  
  margin-bottom: 14px;
  position: relative;
  img {
    width: 100%;
    // height: 120px;
    display: block;
  }
  .cover{
      height:70px;
      overflow: hidden;
  }
  p {
    font-size: 14px;
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding: 6px 2px 0 6px;
  }
  span {
    position: absolute;
    top: 2px;
    right: 5px;
    font-size: 12px;
    color: white;
    padding-left: 13px;
    background: url("../assets/listen.svg") no-repeat;
    background-size: 11px 10px;
    background-position: 0;
    z-index: 2;
  }
  &::after{
    content: " ";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 20px;
    z-index: 2;
    background-image: linear-gradient(180deg,rgba(0,0,0,.2),rgba(0,0,0,0));
  }
}
</style>